package com.ruicar.afs.cloud.account.common.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.ruicar.afs.cloud.account.common.dto.VoucherTemplateEventsDto;
import com.ruicar.afs.cloud.common.core.entity.BaseEntity;
import com.ruicar.afs.cloud.common.modules.contract.enums.VoucherStatus;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
 * @author infinity
 * @version 1.0
 * @date 2020/7/4 18:20
 */
@TableName("voucher_template_events")
@Data
public class VoucherTemplateEvents extends BaseEntity<VoucherTemplateEvents> {

    @ApiModelProperty("埋点编号")
    @NotBlank(message = "埋点编号不能为空")
    private String buriedPointNo ;

    @ApiModelProperty("主事件代码")
    @NotBlank(message = "主事件代码不能为空")
    private String mainBusinessCode ;

    @ApiModelProperty("子事件代码")
    @NotBlank(message = "子事件代码不能为空")
    private String childBusinessCode ;

    @ApiModelProperty("描述")
    private String description ;

    @ApiModelProperty("状态:new-创建 active-生效 invalidity-无效")
    private VoucherStatus status ;

    @ApiModelProperty("删除token")
    private Long deleteToken ;

    public static VoucherTemplateEvents convertFromDto(VoucherTemplateEventsDto dto) {
        VoucherTemplateEvents voucherTemplateEvents = new VoucherTemplateEvents();
        voucherTemplateEvents.setStatus(VoucherStatus.NEW);
        voucherTemplateEvents.setBuriedPointNo(dto.getBuriedPointNo());
        voucherTemplateEvents.setMainBusinessCode(dto.getMainBusinessCode());
        voucherTemplateEvents.setChildBusinessCode(dto.getChildBusinessCode());
        voucherTemplateEvents.setDescription(dto.getDescription());
        return voucherTemplateEvents;
    }
}
